package com.sinping.qh.query.lab;

import com.sinping.qh.query.base.Operator;
import com.sinping.qh.query.base.QueryParams;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author jiahuaiqing
 * @create 2018/6/2
 */
public class LabInspectItemQuery implements QueryParams, Serializable {
    private static final long serialVersionUID = -6003019527845986246L;
    private static Map<String, String> aliasMap = new HashMap<String, String>();
    private static Map<String, Operator> operatorMap = new HashMap<>();

    /**
     * 名称
     */
    private String itemName;

    /**
     * 分类
     */
    private String itemSubcategory;

    private String itemLevel;

    static {
        aliasMap.put("itemName", "item_name");
        aliasMap.put("itemSubcategory", "item_subcategory");
        aliasMap.put("itemLevel", "item_level_");

        operatorMap.put("itemName", Operator.regex);
        operatorMap.put("itemSubcategory", Operator.eq);
        operatorMap.put("itemLevel", Operator.eq);
    }

    @Override
    public String getAlias(String fieldName) {
        return aliasMap.getOrDefault(fieldName, fieldName);
    }

    @Override
    public Operator getOperators(String fieldName) {
        return operatorMap.getOrDefault(fieldName, Operator.eq);
    }
}
